class Food{
    element: HTMLElement
    constructor(){
        this.element = document.getElementById('food')!
    }
    get X(){
        return this.element.offsetLeft
    }
    get Y(){
        return this.element.offsetTop
    }
    // 更新位置
    change(){
        this.element.style.left = this.getRandom() 
        this.element.style.top = this.getRandom() 
    }
    // 取一个0 - 290之间的10的整数倍的数
    getRandom(){
        return Math.round(Math.random()*29) * 10 + 'px'
    }
}
export default Food